﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using WebCommit.Common.Entitys;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel;
using System.Web.Mvc;
using WebCommit.Common.Factories;
using WebCommit.Common.Interfaces;
using WebCommit.SvcL.User;

namespace WebCommit.Web.Models
{

	public class RegisterModel : UserEntity
	{
		[Required(AllowEmptyStrings = false)]
		[Display(Name = "用户名")]
		[RegularExpression("[A-Za-z0-9_]{5,16}", ErrorMessage = "请输入长度为5到16的由字母、数字和下划线组成的用户名！")]
		[Remote("IsUserNameExists","UserMgr",ErrorMessage="此用户名已经被使用")]
		public override string UserName
		{
			get;
			set;
		}
		[Required]
		[Display(Name = "密&nbsp;&nbsp;码")]
		[DataType(DataType.Password)]
		[StringLength(18, MinimumLength = 6, ErrorMessage = "请输入长度为6到18的密码！")]
		public override string Password
		{
			get;
			set;
		}
		[Required]
		[Display(Name = "重复输入密码")]
		[DataType(DataType.Password)]
		[StringLength(18, MinimumLength = 6, ErrorMessage = "请输入长度为6到18的密码！")]
		[Compare("Password", ErrorMessage = "两次输入的密码不一致！")]
		public string RepeatPassword
		{
			get;
			set;
		}
		[Required]
		[Display(Name = "昵称")]
		[StringLength(8, MinimumLength = 2, ErrorMessage = "请输入长度为2到8的昵称！")]
		[Remote("IsNickNameExists", "UserMgr", ErrorMessage = "此昵称已经被使用")]
		public override string NickName
		{
			get;
			set;
		}
		[Required]
		[Display(Name = "真实姓名")]
		[StringLength(8, MinimumLength = 2, ErrorMessage = "请输入您的真实姓名！")]
		public override string TrueName
		{
			get;
			set;
		}
		[Required]
		[Display(Name = "身份证号码")]
		[RegularExpression(@"[\d]{6}(19|20)*[\d]{2}((0[1-9])|(11|12))([012][\d]|(30|31))[\d]{3}[xX\d]*", ErrorMessage = "请输入正确的身份证号码！")]
		public override string IDNumber
		{
			get;
			set;
		}
		[Required]
		[Display(Name = "邮箱")]
		[RegularExpression(@"[\w-]+(\.[\w-]+)*@[\w-]+(\.[\w-]+)+", ErrorMessage = "请输入正确的邮箱地址！")]
		public override string Email
		{
			get;
			set;
		}

		[Required]
		[Display(Name = "密码找回问题")]
		[StringLength(18, MinimumLength = 2, ErrorMessage = "请输入长度为2到18的密码找回问题！")]
		public override string PwdQuestion
		{
			get;
			set;
		}
		[Required]
		[Display(Name = "密码找回答案")]
		[StringLength(18, MinimumLength = 2, ErrorMessage = "请输入长度为2到18的密码找回答案！")]
		public override string PwdAnswer
		{
			get;
			set;
		}

	}

}